//
//  RecruitViewController.m
//  edu
//
//  Created by baobaodp on 13-8-25.
//  Copyright (c) 2013年 baobaodp. All rights reserved.
//

#import "RecruitViewController.h"
#import "RecruitCell.h"
#import "SchoolListViewController.h"
#import "Record.h"
#import "EduViewController.h"
#import "DBbase.h"

@interface RecruitViewController ()

@end

@implementation RecruitViewController

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        // Custom initialization
        self.isWithSearchBar = TRUE;
    }
    return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark -
#pragma mark Table Data Source Methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    [self getRecords];
    return [self.datas count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"RecruitCellIdentifier";
    
    RecruitCell *cell = (RecruitCell *)[tableView
                                    dequeueReusableCellWithIdentifier: cellIdentifier];
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"RecruitCell"
                                                     owner:self options:nil];
        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[RecruitCell class]])
                cell = (RecruitCell *)oneObject;
    }
	
    //    NSUInteger row = [indexPath row];
    //    [cell setData:[self.estimates objectAtIndex:row]];
    
    [self configureCell:cell indexPath:indexPath accessoryType:DISCLOSURE_INDICATOR];
    
    NSUInteger row = [indexPath row];
    [cell setData:[self.datas objectAtIndex:row] index:row];

    //------cell背景透明化--------------------------------------------
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    cell.contentView.backgroundColor = [UIColor clearColor];
    UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
    backView.backgroundColor = [UIColor clearColor];
    cell.backgroundView = backView;
    //--------------------------------------------------
    return cell;
}

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    // Navigation logic may go here. Create and push another view controller.

	SchoolListViewController *detailViewController = [[SchoolListViewController alloc] initWithNibName:@"SchoolListViewController" bundle:nil];


	if (tableView == self.searchDisplayController.searchResultsTableView){
        //		detailViewController.currentLineName = [filteredListContent objectAtIndex:indexPath.row];
        //		detailViewController.currentLineIndex = [[CDataContainer Instance].lineNameArray indexOfObject:[filteredListContent objectAtIndex:indexPath.row]];
	}
	else{
        //		detailViewController.currentLineName = [[CDataContainer Instance].lineNameArray objectAtIndex:indexPath.row];
        //		detailViewController.currentLineIndex = indexPath.row;
	}

    NSUInteger row = [indexPath row];
    [detailViewController setData:[self.datas objectAtIndex:row] index:row];

	[self.navigationController pushViewController:detailViewController animated:YES];

}

-(void)getRecords
{
    //NSString *schId = [userEntry.userInfo getFieldValueByName:@"sch_Id"];
    //NSString *querySql = [NSString stringWithFormat:@"select * from T_Message where sch_Id ='%@' " ,schId];
    
    //const char *sql = [querySql UTF8String];
    
    
    //self.datas = getDbRecords(sql,@"T_Message",[NSArray arrayWithObjects:@"ptn_Id", nil]);
    
    self.datas = [[NSMutableArray alloc]init];
    
    Record *r1 = [[Record alloc]init];
    [r1 addField:@"div" value:@"1"];
    [r1 addField:@"name" value:@"学校类型1"];
    [self.datas addObject:r1];
    
    Record *r2 = [[Record alloc]init];
    [r2 addField:@"div" value:@"2"];
    [r2 addField:@"name" value:@"学校类型2"];
    [self.datas addObject:r2];
    
    Record *r3 = [[Record alloc]init];
    [r3 addField:@"div" value:@"3"];
    [r3 addField:@"name" value:@"学校类型3"];
    [self.datas addObject:r3];
    
}

@end
